Skip to content

Immich: rescan libraries after changes, open-in-Immich links for duplicate groups - #529

Merged
markusressel merged 1 commit into
masterfrom
immich-rescan-and-links
Oct 31, 2026
Merged

markusressel merged 1 commit into
masterfrom
immich-rescan-and-links

Conversation

@markusressel

Copy link
Copy Markdown
Owner

Summary

  • Library rescan (immich.rescan_after_changes, default false): after py-image-dedup really moved or deleted files (never in dry run), it queues a scan (POST /api/libraries/{id}/scan) of the Immich external libraries whose import paths contain the affected files (all external libraries if none matches). At most once per deduplication run (full or incremental, triggered from process_duplicates) and once per batch of executed web UI decisions. Runs in a background thread with a 10s request timeout; an unreachable Immich only logs a warning.
  • Open in Immich links: new GET /api/groups/{id}/immich returns the asset id and link per candidate. Local paths are mapped with the inverse of immich.path_mappings and looked up with one POST /api/search/metadata using filter.originalPath.in (Immich >= v3.2.0); on HTTP 400/422 it falls back to the deprecated originalPath parameter (substring match, filtered exactly client side). Results (and errors) are cached for 60s; Immich errors are returned in error and never fail the group page. The group detail view shows an "open in Immich ↗" link per candidate.
  • immich.public_url: URL of Immich as reachable from the browser for those links, falls back to immich.url. Also exposed in GET /api/integrations/immich (together with rescan_after_changes).

Immich API key permissions

  • asset.read: trash import and asset links (as before).
  • library.read + library.update: only for rescan_after_changes. In Immich (checked against the v3.3.5 OpenAPI spec) GET /api/libraries and POST /api/libraries/{id}/scan are admin only, so the API key must belong to an admin user.

Test plan

  • poetry run pytest (client: path inverse mapping, asset lookup + fallback, library selection/scan, admin permission error; deduplicator: rescan once after real moves, not in dry run / when disabled, Immich down only warns; API: links, caching, public URL, Immich down)
  • npm --prefix web run lint, npm --prefix web run build

🤖 Generated with Claude Code

…h assets

- immich.rescan_after_changes (default false): after files were really moved or
  deleted, queue a scan of the affected Immich external libraries (all of them if
  none matches), at most once per deduplication run / batch of executed user
  decisions. Runs in a background thread, errors are only logged as warnings.
  Needs an admin API key with library.read and library.update.
- GET /api/groups/{id}/immich: Immich asset ids and links per candidate, local
  paths mapped with the inverse of immich.path_mappings, looked up via the
  search filter originalPath.in (Immich >= v3.2.0, falls back to the deprecated
  originalPath parameter). Cached for 60s, Immich errors are reported in the
  response instead of failing.
- immich.public_url: Immich URL as reachable from the browser (falls back to
  immich.url), used for the "open in Immich" links in the group detail page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread py_image_dedup/web/app.py
"asset_id": asset_id,
"url": f"{base_url}/photos/{asset_id}" if asset_id is not None else None,
})
return {"configured": True, "url": base_url, "error": error, "candidates": candidates}
@markusressel
markusressel merged commit 96b64d7 into master Oct 31, 2026
8 checks passed
@markusressel
markusressel deleted the immich-rescan-and-links branch October 31, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants